package io.gitee.zhangbinhub.acp.cloud.oauth.authentication;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import java.io.Serial;
import java.util.Collection;
import java.util.Map;

public class OAuth2UserPasswordAuthenticationToken extends AbstractAuthenticationToken {
    @Serial
    private static final long serialVersionUID = 8370701114478265244L;
    private final Authentication clientPrincipal;
    private final Map<String, Object> additionalParameters;
    private final Object principal;
    private final Object credentials;

    public OAuth2UserPasswordAuthenticationToken(Object principal, Object credentials,
                                                 Authentication clientPrincipal, Collection<GrantedAuthority> authorities,
                                                 Map<String, Object> additionalParameters) {
        super(authorities);
        this.principal = principal;
        this.credentials = credentials;
        this.clientPrincipal = clientPrincipal;
        this.additionalParameters = additionalParameters;
    }

    @Override
    public Object getPrincipal() {
        return principal;
    }

    @Override
    public Object getCredentials() {
        return credentials;
    }

    public Authentication getClientPrincipal() {
        return clientPrincipal;
    }

    public Map<String, Object> getAdditionalParameters() {
        return this.additionalParameters;
    }
}
